Fix potential crash by creating the macOS PAGView render surface on the main thread#3504
Open
leiyue123 wants to merge 6 commits into
Open
Fix potential crash by creating the macOS PAGView render surface on the main thread#3504leiyue123 wants to merge 6 commits into
leiyue123 wants to merge 6 commits into
Conversation
…otential crash on view resize or cache release.
…ent in onCreateSurface.
…gile constructor ordering.
…cos_surface # Conflicts: # src/platform/mac/PAGView.mm
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3504 +/- ##
==========================================
- Coverage 80.57% 80.56% -0.02%
==========================================
Files 620 620
Lines 67021 67021
Branches 19885 19885
==========================================
- Hits 54005 53996 -9
- Misses 9079 9083 +4
- Partials 3937 3942 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
为修复 issue #1870 的崩溃问题,将 macOS PAGView 的渲染 surface 创建放到主线程执行。
当 onCreateSurface 在非主线程被调用时(例如视图缩放或缓存释放触发的重新创建),CGLWindow 需要在主线程访问 NSView 的几何信息,否则可能崩溃。此改动参照 iOS 的既有方案,在非主线程调用时通过 dispatch_async 把 surface 创建推迟到主队列,完成后发出通知触发重绘。PAGView 改名为 PAGView.mm 以支持 C++ 互操作。
同时包含针对该实现的若干代码审查修复:统一异步通知回调方法的小写开头命名、移除 onCreateSurface 中不可达的缓存分支与冗余成员赋值、在派发异步块前对 lock 失败做空指针保护、并将首次 surface 创建移至 weakThis 赋值之后以消除构造期的时序隐患。